// utils/userApi.js
import { request } from './request.js'

// 登录接口
export const login = (data) => {
  return request({
    url: '/auth/login',
    method: 'POST',
    data
  })
}

// 注册接口
export const register = (data) => {
  return request({
    url: '/user/register',
    method: 'POST',
    data
  })
}

// 获取游客信息
export const getGuestInfo = () => {
  return request({
    url: '/user/guest/showGuestInfo',
    method: 'POST',
    data: {}, // POST 必须带 data，即使为空对象
    header: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${uni.getStorageSync('token')}`
    } 
  }) 
}

// 获取工人信息
export const getWorkerInfo = () => {
  return request({
    url: '/user/worker/showWorkerInfo',
    method: 'POST',
    data: {}, // POST 必须带 data，即使为空对象
    header: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${uni.getStorageSync('token')}`
    } 
  }) 
}
// 修改游客密码
export const updateGuestPassword = (data) => {
  return request({
    url: '/user/guest/guestResetPwSelf',
    method: 'POST',
    data
  })
}

// 修改工人密码
export const updateWorkerPassword = (data) => {
  return request({
    url: '/user/worker/workerResetPwSelf',
    method: 'POST',
    data
  })
}


//修改游客基本信息（用户名、手机号）
export const guestSelfUpdate = (data) => {
  return request({
    url: '/user/guest/guestSelfUpdate',
    method: 'POST',
    data,
    header: {
      'Authorization': `Bearer ${uni.getStorageSync('token')}`
    }
  })
}

//修改工人基本信息（用户名、手机号）
export const workerSelfUpdate = (data) => {
  return request({
    url: '/user/worker/workerSelfUpdate',
    method: 'POST',
    data,
    header: {
      'Authorization': `Bearer ${uni.getStorageSync('token')}`
    }
  })
}